#include <stdio.h>
#include <stdlib.h>

#define MAXLINE           80

int main() {
    char name[50], line[MAXLINE];
    FILE *fp;

    printf("%s\n", tmpnam(NULL)); // first temp name

    tmpnam(name); // second tmp name
    printf("%s\n", name);

    if ((fp = tmpfile()) == NULL) {
        perror("tmpfile fail");
        exit(1);
    }

    fputs("one line of output\n", fp); // write to temp file
    rewind(fp);  // then read it back
    if (fgets(line, sizeof(line), fp) == NULL) {
        perror("fgets error");
        exit(1);
    }

    fputs(line, stdout);

    getchar();
//    fclose(fp);

    return 0;
}
